- current_part = Ekylibre::Navigation.part_of(controller.controller_path, action_name)

- main_tools = capture do
  - if current_user
    - count = current_user.unread_notifications.count

    %li{ class: controller_name == 'notifications' ? :active : nil }
      .navbar__notifications.dropdown.show
        .notifications-btn.dropdown-toggle{ data: { toggle: 'dropdown' } }
          = link_to(content_tag(:i), '#', data: { toggle: 'notifications' }, class: 'notifications-btn__icon')
          %span.notifications-btn__counter{ class: !count.zero? ? 'notifications-btn__counter--with-notifications' : nil }
            = count.zero? ? '' : count

        .notifications-menu.dropdown-menu.dropdown-menu-right
          - placeholder_style = current_user.unread_notifications.any? ? 'display: none;' : ''
          .notifications-menu__placeholder.text-center{ style: placeholder_style }= :no_new_notifications.tl

          - current_user.unread_notifications.order(created_at: :desc).each do |notification|
            = link_to backend_notification_path(notification), class: 'notifications-menu__item' do
              = render 'backend/notifications/item', notification: notification

          = link_to :manage_notifications.tl, backend_notifications_path(redirect: request.fullpath), class: 'notifications-menu__link text-center'

    %li= link_to(content_tag(:i, nil, class: 'icon icon-help'), "https://doc.ekylibre.com/v2", title: :help.tl, target: :_blank)

%nav#top

  %ul#menu
    = main_tools
    %li= link_to(content_tag(:i), "#side", data: {toggle: "side"})

  = link_to(backend_root_path, id: "home") do
    %i
    = :home.tl

  - if current_part
    = link_to(current_part.human_name, { controller: "/#{ current_part.default_page.controller }", action: current_part.default_page.action }, id: "part")

  .collapse

    - if true # current_part
      %ul#parts
        - Ekylibre::Navigation.parts.each do |part|
          - next unless part_authorized?(part)
          %li.separator
          :ruby
            attrs = {id: "#{part.name}-part"}
            attrs[:class] = :active if current_part == part
          %li{attrs}
            = link_to(controller: "/#{ part.default_page.controller }", action: part.default_page.action) do
              %i
              = part.human_name

    %ul#user
      = main_tools
      %li.dropdown
        = link_to("#", data: { toggle: 'dropdown' }) do
          = Entity.of_company.full_name
          %i
        %ul#user-menu.dropdown-menu
          %li
            = link_to(backend_myself_path, class: :user) do
              %i
              = current_user.name
          %li
            = link_to(destroy_user_session_path, :method => :delete, class: :signout) do
              %i
              = Authentication::SessionsController.human_action_name(:destroy)
